﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Animaonline.WeatherAPI;

namespace DALDWF.App_Code
{
    class clsWeather
    {
        // Get Current Weather
        public static string CurrentWeather(string city)
        {
            string weatherName;
            try
            {
                WeatherData wD = WeatherAPI.GetWeather(LanguageCode.en_US, city);
                weatherName = wD.condition;
                return weatherName;
            }
            catch 
            { 
                throw; 
            }
        }

        // Get Tommorow Weather
        public static string TommorowWeather(string city)
        {
            string weatherName;
            try
            {
                WeatherData wD = WeatherAPI.GetWeather(LanguageCode.en_US, city);
                weatherName = wD.conditionTOMORROW;
                return weatherName;
            }
            catch
            {
                throw;
            }
        }

        // Get Today Weather
        public static string TodayWeather(string city)
        {
            string weatherName;
            try
            {
                WeatherData wD = WeatherAPI.GetWeather(LanguageCode.en_US, city);
                weatherName = wD.conditionTODAY;
                return weatherName;
            }
            catch 
            { 
                throw; 
            }
        }

        // Get Day 2 Weather
        public static string Day2Weather(string city)
        {
            string weatherName;
            try
            {
                WeatherData wD = WeatherAPI.GetWeather(LanguageCode.en_US, city);
                weatherName = wD.conditionDAY2;
                return weatherName;
            }
            catch
            {
                throw;
            }
        }

        // Get Day 3 Weather
        public static string Day3Weather(string city)
        {
            string weatherName;
            try
            {
                WeatherData wD = WeatherAPI.GetWeather(LanguageCode.en_US, city);
                weatherName = wD.conditionDAY3;
                return weatherName;
            }
            catch
            {
                throw;
            }
        }

        // Get current temperature
        public static double CurrentTempInC(string city)
        {
            double temp = 0.0f;
            try
            {
                WeatherData wD = WeatherAPI.GetWeather(LanguageCode.en_US, city);
                temp = wD.temp_c;
                return temp;
            }
            catch 
            {
                throw;
            }
            
        }

        // Get current temp in F
        public static double CurrentTempInF(string city)
        {
            double temp = 0.0f;
            try
            {
                WeatherData wD = WeatherAPI.GetWeather(LanguageCode.en_US, city);
                temp = wD.temp_f;
                return temp;
            }
            catch
            {
                throw;
            }

        }

        // Get current humidity
        public static string CurrentHumidity(string city)
        {
            try
            {
                WeatherData wD = WeatherAPI.GetWeather(LanguageCode.en_US, city);
                return wD.humidity;
            }
            catch
            {
                throw;
            }
        }

        // High in tomm
        public static string HighInTommorrow()
        {
            clsSystem sys = new clsSystem();
            clsSetting sett = new clsSetting();
            sys.Location = sett.SetUp().Location;

            double temp = 0.0f;
            try
            {
                WeatherData wD = WeatherAPI.GetWeather(LanguageCode.en_US, sys.Location);
                temp = (wD.highTOMORROW - 32) / 1.8;
                double rs = Math.Floor(temp);
                return Convert.ToString(rs);
            }
            catch
            {
                throw;
            }
        }

        // Low in tomm
        public static string LowInTommorrow()
        {
            clsSystem sys = new clsSystem();
            clsSetting sett = new clsSetting();
            sys.Location = sett.SetUp().Location;

            double temp = 0.0f;
            try
            {
                WeatherData wD = WeatherAPI.GetWeather(LanguageCode.en_US, sys.Location);
                temp = (wD.lowTOMORROW - 32) / 1.8;
                double rs = Math.Floor(temp);
                return Convert.ToString(rs);
            }
            catch
            {
                throw;
            }
        }

        // High in next tomm
        public static string HighInNextTommorrow()
        {
            clsSystem sys = new clsSystem();
            clsSetting sett = new clsSetting();
            sys.Location = sett.SetUp().Location;

            double temp = 0.0f;
            try
            {
                WeatherData wD = WeatherAPI.GetWeather(LanguageCode.en_US, sys.Location);
                temp = (wD.highDAY2 - 32) / 1.8;
                double rs = Math.Floor(temp);
                return Convert.ToString(rs);
            }
            catch
            {
                throw;
            }
        }

        // Low in next tomm
        public static string LowInNextTommorrow()
        {
            clsSystem sys = new clsSystem();
            clsSetting sett = new clsSetting();
            sys.Location = sett.SetUp().Location;

            double temp = 0.0f;
            try
            {
                WeatherData wD = WeatherAPI.GetWeather(LanguageCode.en_US, sys.Location);
                temp = (wD.lowDAY2 - 32) / 1.8;
                double rs = Math.Floor(temp);
                return Convert.ToString(rs);
            }
            catch
            {
                throw;
            }
        }

        // High in next next tomm
        public static string HighInNextNextTommorrow()
        {
            clsSystem sys = new clsSystem();
            clsSetting sett = new clsSetting();
            sys.Location = sett.SetUp().Location;

            double temp = 0.0f;
            try
            {
                WeatherData wD = WeatherAPI.GetWeather(LanguageCode.en_US, sys.Location);
                temp = (wD.highDAY3 - 32) / 1.8;
                double rs = Math.Floor(temp);
                return Convert.ToString(rs);
            }
            catch
            {
                throw;
            }
        }

        // Low in next next tomm
        public static string LowInNextNextTommorrow()
        {
            clsSystem sys = new clsSystem();
            clsSetting sett = new clsSetting();
            sys.Location = sett.SetUp().Location;

            double temp = 0.0f;
            try
            {
                WeatherData wD = WeatherAPI.GetWeather(LanguageCode.en_US, sys.Location);
                temp = (wD.lowDAY3 - 32) / 1.8;
                double rs = Math.Floor(temp);
                return Convert.ToString(rs);
            }
            catch
            {
                throw;
            }
        }
    }
}
